<template>
	<view class="back-view">
		<view class="view-background"></view>
		<view class="white-view-back">
			<view class="top-back">
				<view class="top-name">{{pageTitle}}</view>
				<view class="close-back" @click="closeBtnAction">
					<image class="close-img" src="../../../static/close.png"></image>
				</view>
			</view>
			<view class="top-line"></view>
			<view>
				<view class="item-back">
					<uni-easyinput maxlength=299 clearable='false' autoHeight type="textarea" v-model="value"
						placeholder="请填写"></uni-easyinput>
					<view class="item-content">注：备注内容不会发送给用户，仅用于后台信息登记。</view>
				</view>


			</view>
			<view class="bottom-back">
				<view class="bottom-btn bottom-btn-cancel" @click="closeBtnAction">取消</view>
				<view class="bottom-btn" @click="requestData">确定</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			remarkItem: {
				type: Object,
				default: {},
			},

		},
		data() {
			return {
				value: '',
				pageTitle:'添加备注'
			}
		},
		mounted() {
			if (this.remarkItem.remark) {
				this.value = this.remarkItem.remark
				this.pageTitle = '编辑备注'
			}


		},
		methods: {
			//网络请求
			async requestData() {
				if (!this.value) {
					uni.showToast({
						title: '请输入',
						icon: "none"
					})
				} else {
					let _this = this
					//请求参数
					let parmas = {
						'id': _this.remarkItem.id,
						'remark': _this.value,
					}
					const res = await this.$myRequest({
						url: '/admin/leaveMsg/editRemark',
						method: 'PUT',
						data: parmas,
					})
					console.log('返回结果', res)
					if (res.data.code == 200) {
						uni.showToast({
							title: '备注成功'
						})
						_this.$emit("successBack");

						_this.closeBtnAction()
					}
				}

			},
			closeBtnAction() {
				this.$emit('messageRemarkClose')
			}
		},
	}
</script>

<style>
	.back-view {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 9999;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.view-background {
		position: absolute;
		width: 100%;
		height: 100%;
		z-index: -1;
		background-color: rgba(0, 0, 0, 0.3);
	}

	.white-view-back {
		width: 60%;
		padding: 24px;
		max-height: 80%;
		background-color: white;
		margin-top: -70px;
		border-radius: 4px;
	}

	.top-back {
		display: flex;
		justify-content: space-between;
	}

	.top-name {
		font-size: 18px;
		font-weight: normal;
		color: #333333;

	}

	.close-back {
		cursor: pointer;
		width: 20px;
		height: 20px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.close-img {
		width: 12px;
		height: 12px;
	}

	.top-line {
		height: 1px;
		background: #EEEEEE;
		width: 100%;
		margin-top: 20px;
		margin-bottom: 20px;
	}

	.item-back {
		width: 100%;
		margin-bottom: 10px;
	}


	.item-name {
		font-size: 14px;
		font-weight: 400;
		color: #999999;
		width: 60px;
		min-width: 60px;
		text-align: justify;
		text-align-last: justify;
		display: inline-block;
	}

	.item-name-des {

		font-size: 14px;
		font-weight: 400;
		color: #999999;
		margin-right: 16px;
	}

	.item-file-name {
		font-size: 12px;
		font-weight: 400;
		color: #333333;
	}

	.item-content {
		font-size: 12px;
		font-weight: 400;
		color: #999;
		margin-top: 10px;
	}

	.item-img {
		width: 24px;
		height: 24px;
		min-width: 24px;
		margin-right: 8px;
	}

	.bottom-back {
		margin-top: 30px;
		width: 100%;
		min-height: 30px;
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.bottom-btn {
		cursor: pointer;
		width: 104px;
		height: 32px;
		background: #2DA9C5;
		border-radius: 2px;
		color: #FFFFFF;
		font-size: 14px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.bottom-btn-cancel {
		cursor: pointer;
		margin-right: 10px;
		background: #FFFFFF;
		border: 1px solid #EEEEEE;
		color: #333333;
	}
</style>
